/*************************************************************************
	> File Name: media.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月10日 星期五 18时55分15秒
 ************************************************************************/

#include<iostream>
#include <string>

class Country;

//联合国抽象类
class UnitedNations
{
public:
	virtual void declare(std::string message, Country* colleague) = 0;
};

//国家抽象类
class Country
{
public:
	Country(UnitedNations* md) : mediator(md) {}

protected:
	UnitedNations* mediator;
};

//美国
class USA : public Country
{
public:
	using Country::Country;
	void declare(std::string message)
	{
		mediator->declare(message, this);
	}

	void getMessage(std::string message)
	{
		std::cout << "美国获得对方消息:\t" << message << std::endl;
	}
};

//伊拉克
class Iraq : public Country
{
public:
	using Country::Country;
	void declare(std::string message)
	{
		mediator->declare(message, this);
	}

	void getMessage(std::string message)
	{
		std::cout << "伊拉克获得对方消息:\t" << message << std::endl;
	}
};

//安理会-联合国继承类
class UnitedNationsSecurityCouncil : public UnitedNations
{
public:
	void setColleague1(USA* c1)
	{
		colleague1 = c1;
	}

	Country* getColleague1()
	{
		return colleague1;
	}

	void setColleague2(Iraq* c2)
	{
		colleague2 = c2;
	}

	Country* getColleague2()
	{
		return colleague2;
	}

	virtual void declare(std::string message, Country* colleague)
	{
		if (colleague == colleague1)
			colleague2->getMessage(message);
		else
			colleague1->getMessage(message);
	}

private:
	USA* colleague1;
	Iraq* colleague2;
};
